#ifndef CARD_H
#define CARD_H

#include <QString>
/**
 * @brief CardValue
 * 3 - 3
 * ...
 * 9 - 9
 * 10 - A
 * J - B
 * Q - C
 * K - D
 * A - E
 * 2 - F
 * Joker1 - G
 * Joker2 - H
 */

struct Card {
    int v;

    Card() {}
    Card(int x) : v(x) {}

    operator int() const { return v; }
    /*
    bool operator < (const Card& c) const { return v < c.v; }
    bool operator > (const Card& c) const { return v > c.v; }
    bool operator == (const Card& c) const { return v == c.v; }
    bool operator != (const Card& c) const { return v != c.v; }
    */

    char repr() const {
        if (3 <= v && v <= 9)
            return char(v + '0');
        return char(v - 10 + 'A');
    }

    QString name() const {
        if (3 <= v && v <= 10)
            return QString::number(v);
        if (v == 11) return "J";
        if (v == 12) return "Q";
        if (v == 13) return "K";
        if (v == 14) return "A";
        if (v == 15) return "2";
        if (v == 16) return "小\n王";
        return "大\n王";
    }

    static Card fromChar(int c)
    {
        if ('0' <= c && c <= '9')
            return Card(c - '0');
        return Card(c - 'A' + 10);
    }
};

#endif // CARD_H
